package com.qfedu.controller;

import com.qfedu.pojo.req.RotationImageReq;
import com.qfedu.pojo.resp.BaseResp;
import com.qfedu.service.RotationImageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName RotationImageController
 * @Description TODO
 * @Author young
 * @Date 2022-09-27 15:08
 * @Version 1.0
 **/
@RestController
@RequestMapping("/rotationImage")
@Api(tags = "轮播图管理")
public class RotationImageController {
    @Autowired
    RotationImageService rotationImageService;

    @GetMapping("/findByType")
    @ApiOperation(value = "根据轮播图类型查询轮")
    public BaseResp findByType(Integer type){
        return rotationImageService.findByType(type);
    }

    @GetMapping("/findAll")
    @ApiOperation(value = "后台管理,分页查询全部")
    public BaseResp findAll(@RequestParam("page")Integer page, @RequestParam("size")Integer size){
        return rotationImageService.findAll(page,size);
    }

    @PostMapping("/saveOrUpdate")
    @ApiOperation(value = "后台管理,进行增加以及修改")
    public BaseResp saveOrUpdate(@RequestBody RotationImageReq rotationImageReq){
        return rotationImageService.save(rotationImageReq);
    }

    @PostMapping("/delById")
    @ApiOperation(value = "后台管理,删除")
    public BaseResp delById(@RequestBody RotationImageReq rotationImageReq){
        return rotationImageService.delById(rotationImageReq.getId());
    }
}
